package cz.cvut.fit.sin.eventlocator.core;

import java.util.Collections;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import cz.cvut.fit.sin.eventlocator.data.Event;
import cz.cvut.fit.sin.eventlocator.data.Location;

public class EventLocator {

	@Autowired
	private PlaceFinder placeFinder;

	@Autowired
	private EventfulGrabber eventfulGrabber;

	/**
	 * Gets list of Events happening at address
	 * 
	 * @param address
	 * @return
	 * @throws Exception
	 */
	public List<Event> getEvents(String address) throws Exception {
		Location location = placeFinder.getLocation(address);
		if (location == null) {
			return Collections.emptyList();
		}
		return eventfulGrabber.getEvents(location);
	}

}
